<!DOCTYPE html >
<html lang="zh-CN">

    <head>
        <meta charset="utf-8">
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
        <title>runtime</title>
        <link rel="stylesheet" href="../common/mui/mui.css" />
        <link rel="stylesheet" href="../common/common.css" />
    </head>

    <body>

        <div class="mui-content pt0">
            <ul class="mui-table-view ">
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="launchApp">launchApp(打开淘宝)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="getAppVersion">getAppVersion(获取App版本号)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="getQuickVersion">getQuickVersion(获取Quick版本号)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="clearCache">clearCache(清除缓存)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="getGeolocation">getGeolocation(获取地理位置)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="clipboard">clipboard(复制到剪切板)</a>
                </li>
                <li class="mui-table-view-cell">
                    <a class="mui-navigate-right api-class" id="openUrl">openUrl(外部浏览器打开url)</a>
                </li>
            </ul>
        </div>
        <script type="text/javascript" src="../common/mui/mui.js"></script>
        <script type="text/javascript" src="../../dist/quick.js"></script>
        <script type="text/javascript" src="../../dist/quick.native.js"></script>
        <script type="text/javascript" src="../../dist/quick.h5.js"></script>
        <script type="text/javascript" src="../common/common.js"></script>
        <script>
            quick.error(function(message) {
                alert('错误:' + JSON.stringify(message));
            });
            quick.config();
            quick.ready(function() {
                showTips('注册成功');
            });
            window.runApi = function(id) {
                console.log('执行API:' + id);

                switch (id) {
                    case 'launchApp':
                        quick.runtime.launchApp({
                            // android应用的包名
                            packageName: '',
                            // android应用页面类名
                            className: '',
                            // android应用页面配置的ActionName
                            actionName: '',
                            // 页面配置的Scheme名字，适用于Android与iOS
                            scheme: 'taobao://',
                            // 传递的参数。需要目标应用解析获取参数。字符串形式
                            data: 'testdata',
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'getAppVersion':
                        quick.runtime.getAppVersion({
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'getQuickVersion':
                        quick.runtime.getQuickVersion({
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'clearCache':
                        quick.runtime.clearCache({
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'getGeolocation':
                        quick.runtime.getGeolocation({
                            isShowDetail: 1,
                            // 1火星坐标，2地球坐标
                            coordinate: 1,
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'clipboard':
                        quick.runtime.clipboard({
                            text: "测试信息",
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    case 'openUrl':
                        quick.runtime.openUrl({
                            url: "http://www.baidu.com/",
                            success: function(result) {
                                showTips(JSON.stringify(result));
                            },
                            error: function(error) {
                                showTips('失败:' + JSON.stringify(error));
                            }
                        });
                        break;
                    default:
                        console.error('错误！没有相应API');
                }
            };
        </script>

    </body>

</html>